package com.hong.chapter5;

import java.util.Optional;
import java.util.stream.IntStream;

/**
 * Created by hong on 2018/6/3.
 * 若守护线程一直守护主线程则会一直占用资源
 */
public class ThreadJoin2 {
    public static void main(String[] args) throws InterruptedException {
       /* Thread t1 = new Thread(()->{
            try {
                System.out.println("t1 is running");
                Thread.sleep(10_000);
                System.out.println("t1 is done.");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        });
        t1.start();
        t1.join(100,10);

        Optional.of("All of tasks finish done.").ifPresent(System.out::println);
        IntStream.range(1,1000)
                .forEach(i->System.out.println(Thread.currentThread().getName()+"->"+i));*/
       Thread.currentThread().join();
    }
}
